
#pragma once
#include "stdafx.h"

class CLASS_DECLSPEC CWicStream 
{
    friend class CWicBitmapEncoder;
    //==============================================================================
    // CWicStream
    //==============================================================================
public:
    CWicStream(void);
    CWicStream(CWicStream const &);
    virtual ~CWicStream(void);
    CWicStream& operator=(CWicStream const &);

    //==============================================================================
    // IWICStream
    //==============================================================================
public:
    virtual HRESULT STDMETHODCALLTYPE InitializeFromIStream( 
        /* [in] */ IStream *pIStream);

    virtual HRESULT STDMETHODCALLTYPE InitializeFromFilename( 
        /* [in] */ __RPC__in LPCWSTR wzFileName,
        /* [in] */ DWORD dwDesiredAccess);

    virtual HRESULT STDMETHODCALLTYPE InitializeFromMemory( 
        /* [size_is][in] */ __RPC__in_ecount_full(cbBufferSize) BYTE *pbBuffer,
        /* [in] */ DWORD cbBufferSize);

    virtual HRESULT STDMETHODCALLTYPE InitializeFromIStreamRegion( 
        /* [in] */ IStream *pIStream,
        /* [in] */ ULARGE_INTEGER ulOffset,
        /* [in] */ ULARGE_INTEGER ulMaxSize);

    //==============================================================================
    // IStream
    //==============================================================================
public:
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE Seek( 
        /* [in] */ LARGE_INTEGER dlibMove,
        /* [in] */ DWORD dwOrigin,
        /* [out] */ ULARGE_INTEGER *plibNewPosition);

    virtual HRESULT STDMETHODCALLTYPE SetSize( 
        /* [in] */ ULARGE_INTEGER libNewSize);

    virtual /* [local] */ HRESULT STDMETHODCALLTYPE CopyTo( 
        /* [unique][in] */ IStream *pstm,
        /* [in] */ ULARGE_INTEGER cb,
        /* [out] */ ULARGE_INTEGER *pcbRead,
        /* [out] */ ULARGE_INTEGER *pcbWritten);

    virtual HRESULT STDMETHODCALLTYPE Commit( 
        /* [in] */ DWORD grfCommitFlags);

    virtual HRESULT STDMETHODCALLTYPE Revert( void);

    virtual HRESULT STDMETHODCALLTYPE LockRegion( 
        /* [in] */ ULARGE_INTEGER libOffset,
        /* [in] */ ULARGE_INTEGER cb,
        /* [in] */ DWORD dwLockType);

    virtual HRESULT STDMETHODCALLTYPE UnlockRegion( 
        /* [in] */ ULARGE_INTEGER libOffset,
        /* [in] */ ULARGE_INTEGER cb,
        /* [in] */ DWORD dwLockType);

    virtual HRESULT STDMETHODCALLTYPE Stat( 
        /* [out] */ __RPC__out STATSTG *pstatstg,
        /* [in] */ DWORD grfStatFlag);

    virtual HRESULT STDMETHODCALLTYPE Clone( 
        /* [out] */ __RPC__deref_out_opt IStream **ppstm);

    //==============================================================================
    // ISequentialStream
    //==============================================================================
public:
    virtual /* [local] */ HRESULT STDMETHODCALLTYPE Read( 
        /* [length_is][size_is][out] */ void *pv,
        /* [in] */ ULONG cb,
        /* [out] */ ULONG *pcbRead);

    virtual /* [local] */ HRESULT STDMETHODCALLTYPE Write( 
        /* [size_is][in] */ const void *pv,
        /* [in] */ ULONG cb,
        /* [out] */ ULONG *pcbWritten);

private:
    IWICStream  *m_pIWICStream;
};

